//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================

#include <bsp.h>
#include <init.h>
#include <timer.h>

#define PIT_LATCH   ((PIT_ClockRate + krn.uTickRate / 2) / krn.uTickRate)

EXTERN_C DECL_CODEINIT void CDECL InitPIT()
{
    Outl(_TCFG0, 0x00000000);       //prescaler = 0
    Outl(_TCFG1, (3 << 8));           //divider value = 16, mux0 = 1/16

    Outl(_TCNTB2, PIT_LATCH);
    Outl(_TCMPB2, PIT_LATCH - 100);
    Outl(_TCON,  9<<12);            // activate time2
}

unsigned long LastTimerCount = 0;
EXTERN_C void CDECL BspReloadPIT()
{
    //Outl(_TCON,  1<<12);            // activate time2
}

EXTERN_C uint_t CDECL BspGetPITTime()
{
    // bugbug: not implemented
    kprintf ("!!!BspGetPITTime!!!:%s\n", __FILE__);
    return 0;
}
